<?php
	require_once("db_connect.php");
	require_once("safeFunctions.php");
	//check if we got a page to check, otherwise we are start-page
	if(!isset($page)) {
		if(!isset($_GET["page"])) {
			$page = "start";
		}else{
			$page = $_GET["page"];
		}
	}
	$page = safety($page);
	
	if($page == 41) {
		include("mailScript.php");
	}else{
		//check if the page is a num, if it is it is a sub-page
		if(is_numeric($page)) {	
			$scriptQuery = mysqli_query($db, "SELECT script, allowScript FROM pages WHERE id='$page'");
		}else{
			$scriptQuery = mysqli_query($db, "SELECT script, allowScript FROM pages WHERE name='$page'");
		}
	
		if(!$scriptQuery) {
	
		}else{
			$queryArray = $scriptQuery->fetch_assoc();
			if(sizeof($queryArray) > 0) {
				if($queryArray["allowScript"]) {
					echo $queryArray["script"];
				}
			}else{
		
			}
		}
	}
	
?>